<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="pony" tagdir="/WEB-INF/tags" %>
<%@ page import="pony.model.Dog" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>This is a JSP</title>
	<center>
		<h1> Say Hello JSP!</h1>	
	</center>
	<style type="text/css">
		body {
			background-color: #FFCC33;
			text-align: center;
		}
		
		div.mydiv {
			background-color: #330066;
			font-family: Monaco;
			font-size: 14pt;
			color: #FF6600;
		}
		
		span.contact {
			background-color: #660000;
			font-family: Monaco;
			font-size: 14pt;
			color: #CC6600;
		}
		
		span.keywords {
			font-style: italic;
			color: #C0FF3E;
		}
	</style>
	
	<script type="text/javascript">
		window.onload = function() {
			// alert("We still can use javascript...");
			var pdfImg = document.getElementById("downloadPDF");
			pdfImg.onclick = pdfDownloadSubmit;
		};
		
		function pdfDownloadSubmit() {
			document.pdfForm.submit();
		}
	</script>
</head>
<body>
	<%--
	<div class="calc">
		You just input ${inputNum1} and ${inputNum2}.<br />
		And the result is ${calcResult}.
	</div>
	 --%>
	
	<p>
		The attribute is ${gretting}<br />
		The attribute is 
		<%	response.setContentType("text/html; charset=UTF-8");
			String str = (String)request.getAttribute("gretting"); 
			if(str == null) {
				out.println("NULL!!!");
			} else  {
				out.println("This is not NULL!<br />");
			}
			out.print(str);
			// String likeDog = request.getParameter("dog");
		%>
		
		<div class="mydiv">
			<c:choose>
				<c:when test="${param.dog eq 'Yes' }">
					I know you like dogs...
				</c:when>
				<c:when test="${param.dog eq 'No' }">
					Oh... you don't like dogs??? That's really too bad...
				</c:when>
				<c:when test="${param.dog eq null }">
					We all are dog-lovers!!!
				</c:when>
				<%-- <c:otherwise></c:otherwise>  --%>
				<%-- 在<c:choose>的標籤主體中，<c:otherwise>不是必要的標籤! --%>
			</c:choose>
		</div>
		
		<% 	
			Dog dog = (Dog)request.getAttribute("dog");  
			String dogName = dog.getName();
		%>
	</p>
	
	<pony:dogImg subTitle="Hi, how are you?" />
	
	<div class="mydiv">
		Your dog's name is <span class="keywords"><%= dogName %></span>.<br />
		Your dog's color is <span class="keywords">${dog.color}</span>. <br />
		${requestScope.dog.name} can <span class="keywords"><%= dog.bark() %></span>
	</div>&nbsp;<br />
	
	<div class="mydiv">
		Here are my email, phone number and my address. If you want to contact with me... ^^"<br />
		My Email is <span class="contact">${applicationScope.myemail}</span>.<br />
		My phone number is <span class="contact">${applicationScope.myphone}</span>.<br />
		My address is <span class="contact">${applicationScope.myaddress}</span>.<br />
	</div>
	
	<a href="mp3.do">Do You want to listen some music?</a><br />
	<div class="mydiv">
		Do you want to download the PDF file about A Cat and A Dog?
		<form action="storyPDF.do" method="post" name="pdfForm">
			<img src="./images/smallDog.jpg" width="150px" id="downloadPDF" style="cursor: pointer;" />
		</form>
	</div>
</body>
</html>